// pages/balance_withdrawals/balance_withdrawals.js
import {payKeyboardAsync} from "../../../../mycomponent/payKeyboard/PayKeyboardAsync.js";
import Dialog from "../../../../dist/dialog/dialog.js";
var app = getApp();
const skinBehavior = require('../../../../utils/themeSkin/skinBehavior');

Page({
  behaviors: [skinBehavior],
  /**
   * 页面的初始数据
   */
  data: {
    mailLanguage:{},
    language: '',
    // 是否提现到微信
    withdrawToWechat: 0,
    // 是否提现到支付宝
    withdrawToAlipay: 0,
    withdrawToManual: 0,
    supplier: '',
    balance: 0,
    service_money: 0,
    withdrawType: {}, // 提现方法
    info_form: {
      balance_money: ''
    },

    // 选择提现方法
    pay_type: '',

    eupshow: false,

    popupVisible: false,

    hxShow: false,
    action: '',

    msg: '',

    notice: '',

    // 余额字样
    balanceLang: '余额',
    member_id: '',
    converge_pay: false, // 汇聚按钮显示
    show2: false, // 判断
    show3: false, // 银行卡列表
    withList: [], // 银行卡列表
    checkObj: {}, // 选中的银行卡
    actual_amount: '', // 实际到账金额
    poundageHj: '', // 手续费
    cost_money: '', // 提现金额
    poundage_name:'',
    //好灵工
    worker_withdraw_wechat:false,
    worker_withdraw_alipay:false,
    worker_withdraw_bank:false,
    worker_withdraw:{},
    //支付键盘
    payKeyboardShow:false,

    //是否需要支付密码
    need_password:false,
    //是否设置支付密码
    has_password:false,

    manual_name:'',
    // 智E+ start
    eplus_withdraw_bank:false,
    eplus_withdraw_is_auth:false,
    show:false,
    list:[],
    // 智E+ end
    // 提现到银典支付
    silver_point:false,
    bank_card_status:false,
    // 提现到银典支付 end
    // 帮扶中心 start
    support_code:false,
    support_center_withdraw:false,
    support_center_withdraw_name:'帮扶中心',
    support_code_url:'',
    // 帮扶中心 end
    priceDifferencePool:false,
    priceDifferencePool_buttons:[],
    // 提现成功订阅消息模板id
    tmplIds: ['elzZLG5TExM8MOG9P65YDxnFA6m2s3jo_YJEAfW3Ffw', '4pKJTxQka2FNlCibrwSA8tlq0Eh7PTE4D3mHN3JE8MA']
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (options.supplier) {
      this.setData({
        supplier: options.supplier
      });
    }
    if (options.member_id) {
      this.setData({
        member_id: options.member_id
      });
    }
    if(options.name == 'pdp'){
      this.setData({
        priceDifferencePool:true
      })
    }

    this.customizeIncome();
    try {
      var mailLanguage=JSON.parse(wx.getStorageSync('mailLanguage'));
      if (mailLanguage) {
        this.setData({
          mailLanguage:mailLanguage,
          manual_name: mailLanguage.income.name_of_withdrawal + mailLanguage.income.manual_withdrawal
        });
        wx.setNavigationBarTitle({
          title: this.data.mailLanguage.income&&this.data.mailLanguage.income.name_of_withdrawal?this.data.mailLanguage.income.name_of_withdrawal:'提现'
        });
      }
    } catch (e) {
      console.log(e);
    }
    try {
      var value = wx.getStorageSync('balance');
      if (value) {
        this.setData({
          balanceLang: value
        });
        // Do something with return value
      }
    } catch (e) {
      // Do something when catch error
    }
  },
  //自定义提现收入语言
  customizeIncome() {
    try {
      var value = wx.getStorageSync('mailLanguage');
      if (value) {
        let mailLanguage = JSON.parse(value);
        // Do something with return value
        this.setData({
          poundage_name: mailLanguage.income.poundage_name
        });
      }
    } catch (e) {
      // Do something when catch error
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    let language = wx.getStorageSync('langIndex');
    this.setData({ 'language': language.en});
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    if (this.data.supplier === 'supplier') {
      this.getData2();
    } else {
      this.getData();
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
  getData2() {
    var that = this;
    let urlStr = app.getNetAddresss('plugin.supplier.frontend.withdraw.index');
    urlStr += '&member_id=' + this.data.member_id;
    app._getNetWork({
      url: urlStr,
      success: function (resdata) {
        var res = resdata.data;
        if (res.result == 1) {
          that.setData({
            balance: res.data.cost_money,
            service_money: res.data.service_money,
            withdrawType: res.data.type,
            service_type:res.data.service_type
          });
          wx.setNavigationBarColor({
            frontColor: '#ffffff',
            backgroundColor: that.data.themeBaseColor,
            animation: {
              duration: 400,
              timingFunc: 'easeIn'
            }
          });
        } else {
          wx.showToast({
            icon: 'none',
            title: res.msg,
            duration: 1500
          });
        }
      },
      fail: function (res) {
        console.log(res);
      }
    });
  },
  // 智E+ 提现
  onConfirm(e){
    console.log(e,'ddddddddd')
    if(e.detail.radio){
      wx.showModal({
        content:'请选择银行卡',
        showCancel:false
      })
      return
    }
    let json = {
      withdraw_type: '13',
      withdraw_money: this.data.info_form.balance_money,
      bank_card_no:e.detail.radio
    };
    const _this = this
    let url = app.getNetAddresss("finance.balance-withdraw.withdraw");
    app._getNetWork({
      url: url,
      data:json,
      success: (resdata) => {
        let res = resdata.data;
        if (res.result == 1) {
          // this.$dialog.alert({ message: response.msg }).then(() => {
          //   this.$router.go(-1);
          // });
          wx.requestSubscribeMessage({
            tmplIds: _this.data.tmplIds,
            complete: function() {
              wx.showModal({
                content: res.msg,
                showCancel:false,
                success:()=>{
                  this.setData({
                    'info_form.balance_money':'',
                    show:false
                  })
                }
              })
            }
          })
        } else {
          app.tips(res.msg)
        }
      },
      fail: function (res) {
        console.log(res);
      }
    });
  },
  getBankList(){
    let url = app.getNetAddresss("plugin.eplus-pay.frontend.card.bindCardList");
    app._getNetWork({
      url: url,
      success: (resdata) => {
        let res = resdata.data;
        if (res.result == 1) {
          this.setData({
            list:res.data,
          })
          this.getCartWith('eplus');
        } else {
          app.tips(res.msg)
        }
      },
      fail: function (res) {
        console.log(res);
      }
    });
  },
  // 汇聚提现前面的
  towithdrawalHj(e) {
    let typeData = e.target.dataset.index;
    this.setData({
      pay_type: typeData
    });
    if (this.data.pay_type == 5) {
      let urlStr = app.getNetAddresss('plugin.converge_pay.frontend.controllers.converge-pay-bank-card.get-bank-card');
      app._getNetWork({
        url: urlStr,
        success: (resdata) => {
          let res = resdata.data;
          if (res.result == 1) {
            this.setData({
              checkObj: res.data
            });
            let name = res.data.bankName + '(' + res.data.receiverAccountNoEnc.substring(res.data.receiverAccountNoEnc.length - 4) + ')';
            this.setData({
              show2: true,
              'checkObj.bankName': name
            });

            this.getwithList();
            this.getCartWith();
            //
            return;
          } else {
            if (res.data.status == -1) {
              wx.navigateTo({
                url: '/packageA/others/HJinfo/bankCardInformation/bankCardInformation'
              });
            }
            wx.showToast({
              title: res.msg,
              icon: 'none'
            });
            return;
          }
        },
        fail: function (res) {
          console.log(res.msg);
        }
      });
      return;
    }
    this.towithdrawal(typeData);
  },
  all(){
    this.setData({
      'info_form.balance_money':this.data.balance
    })
  },
  // 获取数据
  getData() {
    let that = this;
    let urls = "finance.balance-withdraw.page";
    if(this.data.priceDifferencePool){
      urls = "plugin.price-difference-pool.frontend.modules.pool.controllers.withdraw.page";
    }
    let urlStr = app.getNetAddresss(urls);
    app._getNetWork({
      url: urlStr,
      success: (resdata)=> {
        var res = resdata.data;
        if (res.result == 1) {
          if(this.data.priceDifferencePool){
            this.setData({
              priceDifferencePool_buttons:res.data,
              balance:res.data.pool
            })
            return
          }
          that.setData({
            worker_withdraw_wechat:res.data.worker_withdraw_wechat,
            worker_withdraw_alipay:res.data.worker_withdraw_alipay,
            worker_withdraw_bank:res.data.worker_withdraw_bank,
            worker_withdraw:res.data.extra_data.worker_withdraw,
            balance: res.data.balance,
            withdrawToAlipay: res.data.alipay,
            withdrawToWechat: res.data.wechat,
            withdrawToManual: res.data.manual,
            poundage: res.data.poundage,
            eupshow: res.data.eup_pay,
            converge_pay: res.data.converge_pay,
            need_password:res.data.need_password,
            has_password:res.data.has_password,
            eplus_withdraw_bank:res.data.eplus_withdraw_bank?res.data.eplus_withdraw_bank:false,
            eplus_withdraw_is_auth:res.data.extra_data.eplus_withdraw?res.data.extra_data.eplus_withdraw.is_auth:false,
            silver_point:res.data.silver_point,
            bank_card_status:res.data.bank_card_status,
            support_center_withdraw:res.data.support_center_withdraw?res.data.support_center_withdraw:false,
            support_center_withdraw_name:res.data.support_center_withdraw_name?res.data.support_center_withdraw_name:'帮扶中心'
          });
          wx.setNavigationBarColor({
            frontColor: '#ffffff',
            backgroundColor: that.data.themeBaseColor,
            animation: {
              duration: 400,
              timingFunc: 'easeIn'
            }
          });
        } else {
          wx.showToast({
            icon: 'none',
            title: res.msg,
            duration: 1500
          });
        }
      },
      fail: function (res) {
        console.log(res);
      }
    });
  },
  payKeyboardComplete(evt){
    payKeyboardAsync.complete(evt.detail);
  },
  getPayKeyboardPassword(){
    this.setData({
      show2: false,
      show3: false,
      payKeyboardShow:true
    });
    return new Promise((resove,reject)=>{
      payKeyboardAsync.addCompleteFn((pass)=>{
        resove(pass);
      });
    });
    // let pass = await this.getPayKeyboardPassword();
    // console.log(pass);
  },
  payKeyboardClose(){
    this.setData({payKeyboardShow:false});
  },
  confirm(e) {
    // this.setData({payKeyboardShow:true})
    // return;
    let type = e.currentTarget.dataset.num;
    let text = e.currentTarget.dataset.text;
    if(this.data.priceDifferencePool){
      // price-difference-pool 插件的提现
      this.priceDifferencePool_confirm(e.currentTarget.dataset.num);
      return
    }
    if((text == 'worker_withdraw_wechat' && this.data.worker_withdraw.wechat_is_register == 0)  || (text == 'worker_withdraw_bank' && this.data.worker_withdraw.bank_is_register == 0)){
      if(text == 'worker_withdraw_wechat' ){
        wx.navigateTo({
          url: '/packageI/worker/index/index?register_type_Id=2&path=balance_withdrawals',
        })
      }else{
        wx.navigateTo({
          url: '/packageI/worker/index/index?register_type_Id=1&path=balance_withdrawals',
        })
      }
    
      return;
    }
    this.setData({
      pay_type: type
    });
    switch (this.data.pay_type) {
    case '3':
      this.manualVerify(this.data.pay_type);
      break;
    case '4':
      this.checkEup(this.data.pay_type);
      break;
    case '5':
      this.checkHx(this.data.pay_type);
      break;
    case '6':
      if (this.data.info_form.balance_money == '') {
        wx.showToast({
          title: '请输入提现金额',
          icon: 'none'
        });
        return;
      }
      this.checkHJ(this.data.pay_type);
      break;
    case '15':
      this.support_center()
      break
    default:
      this.confirmPost(this.data.pay_type);
      break;
    }
  },
  support_code_close(){
    this.setData({
      support_code:false
    })
  },
  support_center(){
    app._postNetWork({
      url: app.getNetAddresss("plugin.support-center.frontend.withdraw.get-write-off-code"),
      data: {
        withdraw_money: this.data.info_form.balance_money,
        withdraw_type: '15'
      },
      success: (resdata) => {
        let res = resdata.data;
        if (res.result == 1) {
          this.setData({
            support_code_url:res.data.url,
            support_code:true
          })
        } else {
          app.tips(res.msg)
        }
      },
      fail: function (res) {
        console.log(res.msg);
      }
    });
  },
  checkOut(e) {
    let item = e.target.dataset.item || e.currentTarget.dataset.item;
    item.check = !item.check;

    let data = this.data.withList;
    data.map(items => {
      if (items.id == item.id) {
        items.check = item.check;
      } else {
        items.check = false;
      }
    });

    if (item.check == true) {
      this.setData({
        show3: false,
        show2: true,
        checkObj: item,
        withList: data
      });
    }
  },
  getToTitle() {
    let urlStr = app.getNetAddresss('plugin.converge_pay.frontend.controllers.converge-pay-bank-card.set-bank-card');
    app._postNetWork({
      url: urlStr,
      data: { set: this.data.checkObj },
      success: (resdata) => {
        var res = resdata.data;
        if (res.result == 1) {
          // 有资格提现
          this.confirmPost(this.data.pay_type);
        } else {
          wx.showToast({
            title: res.msg,
            icon: 'none',
            duration: 1500
          });
        }
      },
      fail: function (res) {
        console.log(res);
      }
    });
  },
  withGotiem() {
    console.log(this.data.checkObj, '选中的项');
    this.getToTitle();
    return;
  },
  backGo() {
    this.setData({
      show2: true,
      show3: false
    });
  },
  backTap() {
    this.setData({
      show2: false,
      show3: false
    });
  },
  gotoList() {
    this.setData({
      show2: false,
      show3: true
    });
  },
  async priceDifferencePool_confirm(type){
    console.log(type,'dddd')
    if (parseFloat(this.data.info_form.balance_money) > parseFloat(this.data.priceDifferencePool_buttons.pool)) {
      wx.showToast({
        icon: 'none',
        title: '提现金额不可大于您的'+that.data.balanceLang,
        duration: 1500
      });
      return;
    }
    let urlStr = app.getNetAddresss("plugin.price-difference-pool.frontend.modules.pool.controllers.withdraw.apply");
    if(this.data.need_password==true){  //开启支付密码验证
      let pass = await this.getPayKeyboardPassword();
      urlStr += '&password=' + pass;
    }
    urlStr += '&pay_id=' + type;
    urlStr += '&amount=' + this.data.info_form.balance_money;
    app._getNetWork({
      url: urlStr,
      success: (resdata)=> {
        var res = resdata.data;
        if (res.result == 1) {
          wx.showModal({
            content: res.msg,
            showCancel:false,
            complete: (res) => {
              if (res.confirm) {
                this.getData();
                this.setData({
                  'info_form.balance_money':''
                })
              }
            }
          })
        } else {
          wx.showToast({
            icon: 'none',
            title: res.msg,
            duration: 1500
          });
        }
      },
      fail: function (res) {
        console.log(res);
      }
    });
  },
  async confirmPost(type) {
    // withdraw_money
    var that = this;

    if (parseFloat(this.data.info_form.balance_money) > parseFloat(this.data.balance)) {
      wx.showToast({
        icon: 'none',
        title: '提现金额不可大于您的'+that.data.balanceLang,
        duration: 1500
      });
      return;
    }
    if (
      this.data.info_form.balance_money == undefined ||
      this.data.info_form.balance_money <= 0 ||
      this.data.info_form.balance_money == 0
    ) {
      wx.showToast({
        icon: 'none',
        title: '提现金额不可低于0',
        duration: 1500
      });
      return;
    }

    if(this.data.need_password==true && this.data.has_password==false){
      let confirmFlag = await app.confirm("请先设置支付密码");
      if(confirmFlag) {
        wx.navigateTo({
          url: '/packageA/member/set_balance_password/set_balance_password'
        });
      }
      return;
    }
    if(type == 13){
      if(this.data.eplus_withdraw_is_auth == 0){
        wx.showModal({
          content: '请先完成认证',
          showCancel:false,
          success:(res)=>{
            wx.navigateTo({
              url: '/packageF/others/wisdom/wisdomBindTask/wisdomBindTask',
            })
          }
        })
        return
      }else{
        this.getBankList()
        return
      }
    }
    if(type == 14){
      // 银典支付 判断是否完善 会员中心-银行卡信息 
      if(!this.data.bank_card_status) {
        wx.showModal({
          content: '该会员未添加默认银行卡',
          showCancel:false,
          success :(res)=> {
            if (res.confirm) {
              wx.navigateTo({
                url: '/packageA/member/memberBank/memberBank',
              })
            }
          }
        })
        return
      }
    }

    let urlStr = app.getNetAddresss('finance.balance-withdraw.withdraw');
    urlStr += '&withdraw_type=' + type;
    urlStr += '&withdraw_money=' + this.data.info_form.balance_money;

    if(this.data.need_password==true){  //开启支付密码验证
      let pass = await this.getPayKeyboardPassword();
      urlStr += '&password=' + pass;
    }

    if(this.isLocks) return;
    this.isLocks = true;

    app._getNetWork({
      url: urlStr,
      success: (resdata)=> {
        this.isLocks = false;
        var res = resdata.data;
        if (res.result == 1) {
          that.setData({
            show2: false
          });
          wx.requestSubscribeMessage({
            tmplIds: that.data.tmplIds,
            complete: function() {
              wx.showModal({
                title: '提示',
                content: res.msg,
                showCancel: false,
                success (res) {
                  if (res.confirm) {
                    wx.navigateBack({
                      delta: 1
                    });
                  }
                }
              })
            }
          })
        } else {
          if(res.data.min_redirect_url){
            Dialog.alert({
              message: res.msg,
            }).then(() => {
              wx.navigateTo({
                url: "/packageC/member/searchAll/searchAll"
              })
            });
          }else{
              wx.showToast({
                icon: 'none',
                title: res.msg,
                duration: 1500
              });
          }
       
 
        }
      },
      fail: function (res) {
        this.isLocks = false;
        console.log(res);
      }
    });
  },
  // 手动提现验证
  manualVerify(type) {
    var that = this;
    if (parseFloat(this.data.info_form.balance_money) > parseFloat(this.data.balance)) {
      wx.showToast({
        icon: 'none',
        title: '提现金额不可大于您的'+that.data.balanceLang,
        duration: 1500
      });
      return;
    }

    if (
      this.data.info_form.balance_money == undefined ||
      this.data.info_form.balance_money <= 0 ||
      this.data.info_form.balance_money == 0
    ) {
      wx.showToast({
        icon: 'none',
        title: '提现金额不可低于0',
        duration: 1500
      });
      return;
    }

    if(this.isLocks) return;
    this.isLocks = true;

    let urlStr = app.getNetAddresss('finance.balance-withdraw.is-can-submit');
    app._postNetWork({
      url: urlStr,
      showToastIn: false,
      // data: _url,
      success: (resdata)=> {
        this.isLocks = false;
        var res = resdata;
        if (res.data.result == 1) {
          if (res.data.data.status) {
            that.confirmPost(type); // 提现
          } else {
            that.setManualInfo(type, res.data.data.manual_type);
          }
        } else {
          wx.showToast({
            icon: 'none',
            title: res.msg,
            duration: 1500
          });
        }
      },
      fail: function (res) {
        this.isLocks = false;
        console.log(res.msg);
      }
    });
  },
  setManualInfo(type, manual_type) {
    let msg = '';
    let routerPath = '';
    switch (manual_type) {
    case 'bank':
      msg = '请先填写银行卡信息';
      routerPath = 'memberBank';
      break;
    case 'wechat':
      msg = '请先填写微信信息';
      routerPath = 'info';
      break;
    case 'alipay':
      msg = '请先填写支付宝信息';
      routerPath = 'info';
      break;
    default:
      break;
    }

    // let that = this;
    wx.showModal({
      title: '提示',
      content: msg,
      success(res) {
        if (res.confirm) {
          if (routerPath == 'memberBank') {
            wx.navigateTo({
              url: '/packageA/member/memberBank/memberBank'
            });
          } else if (routerPath == 'info') {
            wx.navigateTo({
              url: '/packageA/member/info/info'
            });
          }
        } else if (res.cancel) {
          console.log('用户点击取消');
        }
      }
    });
  },
  checkEup(type) {
    var that = this;
    if(this.isLocks) return;
    this.isLocks = true;

    let urlStr = app.getNetAddresss('plugin.eup-pay.api.account.pi-account');
    app._postNetWork({
      url: urlStr,
      showToastIn: false,
      data: _url,
      success: (resdata)=> {
        this.isLocks = false;
        var res = resdata;
        if (res.result == 1) {
          if (res.data.bool == 1) {
            that.confirmPost(type); // 提现
          }
        } else if (res.result == 0) {
          wx.showModal({
            title: '提示',
            content: msg,
            success(res) {
              if (res.confirm) {
                wx.navigateTo({
                  url: '/packageA/member/info/info'
                });
              } else if (res.cancel) {
                console.log('用户点击取消');
              }
            }
          });
        }
      },
      fail: function (res) {
        this.isLocks = false;
        console.log(res.msg);
      }
    });
  },
  _initHxpay() {
    this.setData({
      action: '',
      msg: '',
      notice: ''
    });
  },
  // 获取银行卡列表
  getwithList() {
    let urlStr = app.getNetAddresss('plugin.converge_pay.frontend.controllers.converge-pay-bank-card.get-bank-card-list');
    app._getNetWork({
      url: urlStr,
      success: (resdata) => {
        var res = resdata.data;
        if (res.result == 1) {
          if (res.data.length == 0) {
            wx.showToast({
              title: '请先去添加银行卡',
              icon: 'none'
            });
            wx.navigateTo({
              url: '/packageA/others/HJinfo/bankCardInformation/bankCardInformation'
            });
          }
          res.data.map(item => {
            item.check = false;
            if (item.receiverAccountNoEnc != '' && item.receiverAccountNoEnc != null) {
              item.bankName += '(' + item.receiverAccountNoEnc.substring(item.receiverAccountNoEnc.length - 4) + ')';
            }
          });
          this.setData({
            withList: res.data
          });
        } else {
          wx.showToast({
            icon: 'none',
            title: res.msg,
            duration: 1500
          });
          setTimeout(() => {
          }, 2000);
        }
      },
      fail: function (res) {
        console.log(res);
      }
    });
  },
  show1CloseBtn() {
    this.setData({
      show2: false,
      show3: false,
      show:false
    });
  },
  // 获取手续费
  getCartWith(type) {
    let urlStr = '';
    if (type == 'suppier') {
      urlStr = app.getNetAddresss('plugin.supplier.frontend.withdraw.converge-withdraw');
    } else {
      urlStr = app.getNetAddresss('finance.balance-withdraw.converge-withdraw');
      urlStr += '&withdraw_money=' + this.data.info_form.balance_money;
    }
    app._getNetWork({
      url: urlStr,
      success: (resdata) => {
        var res = resdata.data;
        if (res.result == 1) {
          this.setData({
            poundageHj: res.data.poundage,
            actual_amount: res.data.actual_amount,
            cost_money: res.data.cost_money
          });
          if(type == 'eplus'){
            this.setData({
              show:true
            })
          }
        } else {
          wx.showModal({
            title: '提示',
            content: res.msg
          });
        }
      },
      fail: function (res) {
        console.log(res.msg);
      }
    });
  },
  // 汇聚提现
  checkHJ(type) {
    if(this.isLocks) return;
    this.isLocks = true;
    
    let urlStr = app.getNetAddresss('plugin.converge_pay.frontend.controllers.converge-pay-bank-card.get-bank-card');
    app._getNetWork({
      url: urlStr,
      success: (resdata) => {
        this.isLocks = false;
        var res = resdata.data;
        if (res.result == 1) {
          this.setData({
            checkObj: res.data
          });
          let name = res.data.bankName + '(' + res.data.receiverAccountNoEnc.substring(res.data.receiverAccountNoEnc.length - 4) + ')';
          this.setData({
            show2: true,
            'checkObj.bankName': name
          });

          this.getwithList();
          this.getCartWith();
        // this.confirmPost(type)
        } else {
          if (res.data.status == -1) {
            wx.navigateTo({
              url: '/packageA/others/HJinfo/bankCardInformation/bankCardInformation'
            });
          }
          wx.showModal({
            title: '提示',
            content: res.msg
          });
        }
      },
      fail: function (res) {
        this.isLocks = false;
        console.log(res.msg);
      }
    });
  },
  submitbrank() {
    app._postNetWork({
      url: this.data.action,
      showToastIn: false,
      data: {
        ipsRequest: this.data.msg
      },
      success: function (resdata) {
        wx.navigateBack({
          delta: 1
        });
      },
      fail: function (res) {}
    });
  },
  towithdrawal(e) {
    this.setData({
      pay_type: e.currentTarget.dataset.index
    });
    const that = this;
    if (that.data.balance == undefined || this.data.balance <= 0 || this.data.balance == 0) {
      wx.showToast({
        icon: 'none',
        title: '提现金额不可低于0',
        duration: 1500
      });
      return;
    }
    let urlStr = app.getNetAddresss('plugin.supplier.frontend.withdraw.withdraw');
    urlStr += '&apply_type=' + this.data.pay_type;
    urlStr += '&member_id=' + this.data.member_id;
    app._getNetWork({
      url: urlStr,
      success: (resdata)=> {
        var res = resdata.data;
        if (res.result == 1) {
          this.getData2();
          wx.showToast({
            title: res.msg,
            icon: 'none',
            duration: 1500,
            success: function () {
              setTimeout(function () {
                // 要延时执行的代码
                wx.navigateBack({
                  delta: 1
                });
              }, 1500); // 延迟时间
            }
          });
        } else {
          wx.showToast({
            icon: 'none',
            title: res.msg,
            duration: 1500
          });
        }
      },
      fail: function (res) {
        console.log(res);
      }
    });
  },
  balanceMoneyinp(e) {
    let val = e.detail.value;
    this.setData({
      'info_form.balance_money': val
    });
  }
});



